package org.example.service.impl;

import org.example.dao.RoomDao;
import org.example.entity.Room;
import org.example.service.RoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoomServiceImpl implements RoomService {

    private final RoomDao roomDao;

    @Autowired
    public RoomServiceImpl(RoomDao roomDao) {
        this.roomDao = roomDao;
    }

    @Override
    public List<Room> getAllRooms() {
        return roomDao.getAllRooms();
    }

    @Override
    public Room getRoomById(Integer id) {  // Change to Long to match RoomDao method signature
        return roomDao.getRoomById(id);
    }
/*
    @Override
    public void createRoom(Room room) {
        roomDao.createRoom(room);
    }

    @Override
    public void updateRoom(Integer id, Room room) {  // Change to Long to match RoomDao method signature
        room.setId(id); // Ensure the ID is set for update
        roomDao.updateRoom(room);
    }
*/
    @Override
    public void deleteRoom(Integer id) {  // Change to Long to match RoomDao method signature
        roomDao.deleteRoom(id);
    }


    @Override
    public void addRoom(Room room) {  // Implement the missing addRoom method
        roomDao.createRoom(room);  // Assuming createRoom handles adding a new room
    }

    @Override
    public void updateRoom(Integer id,Room room) {
        room.setId(id);
        roomDao.updateRoom(room);
    }

    @Override
    public List<Room> getAvailableRooms() {
        return roomDao.getAvailableRooms(); // 调用 DAO 方法查询可用房间
    }


}
